package com.lrkj.payfee.mapper;

import com.lrkj.payfee.domain.RuleCost;
import com.lrkj.payfee.domain.vo.AdueRecordVo;
import com.lrkj.payfee.vo.BillDetailVo;
import com.lrkj.payfee.vo.BillVo;
import com.lrkj.payfee.vo.ChangeFeeVo;
import com.lrkj.payfee.vo.NormChargeVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 常规费用单Mapper接口
 *
 * @author yajun_ren
 * @date 2021-07-30
 */
@Component
public interface RuleCostMapper {
    /**
     * 查询常规费用单
     *
     * @param costId 常规费用单ID
     * @return 常规费用单
     */
    public RuleCost selectRuleCostById(String costId);

    /**
     * 查询常规费用单列表
     *
     * @param ruleCost 常规费用单
     * @return 常规费用单集合
     */
    public List<RuleCost> selectRuleCostList(RuleCost ruleCost);

    /**
     * 新增常规费用单
     *
     * @param ruleCost 常规费用单
     * @return 结果
     */
    public int insertRuleCost(RuleCost ruleCost);

    /**
     * 修改常规费用单
     *
     * @param ruleCost 常规费用单
     * @return 结果
     */
    public int updateRuleCost(RuleCost ruleCost);

    /**
     * 删除常规费用单
     *
     * @param costId 常规费用单ID
     * @return 结果
     */
    public int deleteRuleCostById(String costId);

    /**
     * 批量删除常规费用单
     *
     * @param costIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteRuleCostByIds(String[] costIds);


    /**
     * 批量新增
     */
    public int doSaveList(@Param("saveBeans") List<RuleCost> saveBeans);
    int updateBatch(@Param("updList") List<RuleCost> updList);


    /**
     * 通过收费标准+房屋ID 获取最后一条费用记录
     */
    public String getMaxTime(String normId,String roomId);

    /**
     * 通过IDS 获取列表
     */
    public List<RuleCost> selectRuleCostIds(String[] costIds);

    /**
     * 查询房间费用
     *
     * */
    public List<AdueRecordVo> selectAdueRecord(AdueRecordVo adueRecordVo);

    /**
     * 通过收款单ID查询到   费用单据
     *
     * **/
    public List<RuleCost> selectByReceiptId(@Param("receiptId") String receiptId);

    /**
     * 批量重置费用单状态,费用
     * **/
    public int batchResetting(@Param("updateBeans") List<RuleCost> updateBeans);


    /**
     * 通过抄表记录删除费用单
     * copyId 抄表记录ID
     * @return 结果
     */
    public int deleteRuleCostByCopyId(String[] copyIds );

    /**
     * 更新结账期间
     * **/
    public int updateFiscalPeriod(@Param("params") Map<String, Object> params);


    /***
     *
     * 查询账期内生成的账单
     *
     * */
    List<RuleCost> selectFeeFormByFiscalPeriodList(NormChargeVo normChargeVo);


    /**
     * 改费
     * **/
    public int changeFee(@Param("updateBeans") List<ChangeFeeVo> changeFeeVos);

    /**
     * 拆费原始单子修改
     * **/
    public int updateDemolitionFee(@Param("updateBeans") List<RuleCost> ruleCosts);

    //房间欠费金额
    public BigDecimal roomAmountOwed(@Param("roomId") String roomId);

    //房间账单明细记录
    public List<BillDetailVo> roomBillDetail(@Param("roomId") String roomId);

    //更新费用单欠费金额
    public int updateAmountOwed(@Param("updateBeans") List<RuleCost> ruleCosts);


    /**
     * 根据房屋id查询欠费数量
     * @param roomId
     * @return
     */
    public int arrearageCountByRoomId(String roomId);
}
